package cn.com.hori.cms.controller;

import cn.com.hori.cms.entities.ContentPublish;
import cn.com.hori.cms.model.ColumnAndContent;
import cn.com.hori.cms.model.CommonResponse;
import cn.com.hori.cms.service.UserShowService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 刘艺
 * @date 2018/3/14 17:29
 */

@RestController
@RequestMapping("/smc/user-show")
public class UserShowController {
    private static Logger logger = LoggerFactory.getLogger(UserShowController.class);

    @Autowired
    private UserShowService userShowService;

    @GetMapping("/getColumnAndContent")
    public CommonResponse getAllColumnAndContent() {
        List<ColumnAndContent> columnAndContents = userShowService.getAllColumn();
        return new CommonResponse<>(columnAndContents);
    }


    @GetMapping("/getContentList")
    public CommonResponse getContentList(@RequestParam String columnId) {
        ColumnAndContent columnAndContent = userShowService.getContentList(columnId);
        return new CommonResponse<>(columnAndContent);
    }

    @GetMapping("/getContent")
    public CommonResponse getContent(@RequestParam String contentId) {
        ContentPublish contentPublish = userShowService.getContent(contentId);
        return new CommonResponse(contentPublish);
    }
}
